<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>

  <body></body>
  <script>
    // 元字符
    /*       // 匹配至少要有一个数字
      let reg=/\d/;
      var str='123'
      var str1='aaa'
        var str2='a123'
      console.log(reg.test(str))
      console.log(reg.test(str1))
      console.log(reg.test(str2)) */
    /*     // 匹配至少含有任意一个非数字的字符
      let reg=/\D/;
      var str='123'
      var str1='aaa'
        var str2='a123'
      console.log(reg.test(str))
      console.log(reg.test(str1))
      console.log(reg.test(str2)) */

    /*   // 匹配至少含有一个字母或数字或者下划线
  let reg = /\w/;
  var str = '123'
  var str1 = 'aaa'
  var str2 = '#'
  console.log(reg.test(str))
  console.log(reg.test(str1))
  console.log(reg.test(str2)) */
    /*   // 匹配至少含有一个不是字母或数字或者下划线
   let reg = /\W/;
  var str = '123'
  var str1 = 'aaa'
  var str2 = '#'
  console.log(reg.test(str))
  console.log(reg.test(str1))
  console.log(reg.test(str2)) */
    /*   // 匹配至少任意的空白符
  let reg = /\s/;
  var str = '123'
  var str1 = 'aa a'
  var str2 = '#'
  console.log(reg.test(str))
  console.log(reg.test(str1))
  console.log(reg.test(str2)) */
    /*  // 匹配至少含有一个不是空白符的字符
  let reg = /\S/;
  var str=''
   var str1='1   2  3'
  console.log(reg.test(str))
  console.log(reg.test(str1)) */
    /*   // 匹配至少含有一个不是空白符的字符
   let reg = /./;
  var str=''
   var str1='1   2\n  3'
  console.log(reg.test(str))
  console.log(reg.test(str1)) */
  /*   // 匹配行首的文本以谁开始
    let reg = /^\d/;
    var str = " 23";
    var str1 = "1   2\n  3";
    var str2 = "#1   2\n  3";
    var str3 = "a1   2\n  3";
    console.log(reg.test(str));
    console.log(reg.test(str1));
    console.log(reg.test(str2));
    console.log(reg.test(str3)); */
      // 匹配行首的文本以谁开始
      let reg = /\d$/;
    var str = " 23";
    var str1 = "1   2\n  ";
    var str2 = "#1   2\n  #";
    var str3 = "a1   2\n  a";
    console.log(reg.test(str));
    console.log(reg.test(str1));
    console.log(reg.test(str2));
    console.log(reg.test(str3));

    // var reg=/[0-9]|[a-z]/
    // console.log(reg.test('123112asdasA'))
  </script>
</html>
